package cn.tedu.ivos2.vehicle.controller;

import cn.tedu.ivos2.base.response.JsonResult;
import cn.tedu.ivos2.user.pojo.dto.UserQuery;
import cn.tedu.ivos2.vehicle.pojo.dto.VehicleQuery;
import cn.tedu.ivos2.vehicle.pojo.dto.VehicleSaveParam;
import cn.tedu.ivos2.vehicle.pojo.vo.VehicleVO;
import cn.tedu.ivos2.vehicle.service.VehicleService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 边拾柱
 * @date 2025/1/4 16:40
 */
@Slf4j
@RestController
@RequestMapping("/v1/vehicle")
@Api(tags = "3. 车辆模块")
public class VehicleController {


    @Autowired
    private VehicleService vehicleService;

    @GetMapping("select")
    @ApiOperation("查询车辆信息")
    @ApiOperationSupport(order = 10)
    public JsonResult selectVehicle(VehicleQuery vehicleQuery){
        log.debug("开始查询车辆信息,参数：{}", vehicleQuery);
        List<VehicleVO> vehicleVOS = vehicleService.selectVehicle(vehicleQuery);
        return JsonResult.ok(vehicleVOS);
    }


    @PostMapping("save")
    @ApiOperation("保存/更新车辆信息")
    @ApiOperationSupport(order = 20)
    public JsonResult saveVehicle(VehicleSaveParam vehicleSaveParam) {
        log.debug("保存车辆参数",vehicleSaveParam);
        vehicleService.saveVehicle(vehicleSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    @ApiOperation("删除车辆信息")
    @ApiOperationSupport(order = 30)
    public JsonResult deleteVehicle(@PathVariable Long id) {
        log.debug("删除车辆，参数：{}",id);
        vehicleService.deleteVehicle(id);
        return JsonResult.ok();
    }
}
